#ifndef TABLEENTRY_H_
#define TABLEENTRY_H_

#include <iostream>
#include <string>

enum Type { T_ERROR, T_VOID, T_INT, T_CHAR };
enum Attribute { VA_ERROR, VA_SIMPLE, VA_ARRAY, VA_PARAM = 4 };

typedef struct {
	Attribute attrib;
	int arraySize;
} VariableAttribute;

/*
typedef struct {
	Type type;
	int addr;
	Attribute attrib;
	bool param;
} attr;
*/

class attr {
public:
	attr();
	virtual ~attr();
	
	Type type;
	int addr;
	Attribute attrib;
	bool param;
};

class TableEntry
{
public:
	enum EntryType { VARIABLE, FUNCTION };
	
	TableEntry(EntryType et);
	virtual ~TableEntry();
	
	virtual EntryType getEntryType() const;
	
	virtual attr getAttr() const = 0;
	
	virtual int getAddress() const;
	virtual int setAddress(int address);
	
	virtual void setName(std::string name);
	virtual std::string getName() const;
	
	virtual std::ostream& inserter(std::ostream &os) const = 0;
	
protected:
	EntryType entryType;
	std::string name;
	int address;
};

/**
 * Insertion operator overloading for Table Entries
 */
inline std::ostream& operator << (std::ostream &os, const TableEntry &te) {
	return te.inserter(os);
}

#endif /*TABLEENTRY_H_*/
